select option trigger in js

91

select option trigger in js -

/*html*/
<select id="sel" onchange='alert("changed")'>
  <option value='1'>One</option>
  <option value='2'>Two</option>
  <option value='3' selected>Three</option>
</select>

/*Function js*/
var select = document.querySelector('#sel'),
    input = document.querySelector('input[type="button"]');
select.addEventListener('change',function(){
    alert('Yare yare daze');
});

/*RESULT*/
/*When change value trigger alert('Yare yare daze') */



Comments

Submit
0 Comments